package com.dji.sample.component.event;
/**
 * @author 10587
 * @date 2022/9/9
 */

import com.dji.sample.manage.model.enums.DeviceStatusEnum;
import org.springframework.context.ApplicationEvent;

import java.time.Clock;

/**
 * @author yjt
 * @date 2022-09-09
 * @description:
 */
public class DeviceStatusChangeEvent extends ApplicationEvent {

    private Integer status;

    private String deviceSn;

    private String message;

    private String cacheKey;


    public DeviceStatusChangeEvent(Object source) {
        super(source);
    }

    public DeviceStatusChangeEvent(Object source, Clock clock) {
        super(source, clock);
    }

    public DeviceStatusChangeEvent offline(String deviceSn){
         this.deviceSn=deviceSn;
         this.status= DeviceStatusEnum.OFFLINE.getVal();
         this.cacheKey="devicesPositionOSDServiceImpl";
         this.message=deviceSn+" offline";
         return this;
    }

    public DeviceStatusChangeEvent online(String deviceSn){
        this.status=DeviceStatusEnum.ONLINE.getVal();
        this.deviceSn=deviceSn;
        this.message=deviceSn+" online";
        return this;
    }


    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getDeviceSn() {
        return deviceSn;
    }

    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCacheKey() {
        return cacheKey;
    }

    public void setCacheKey(String cacheKey) {
        this.cacheKey = cacheKey;
    }

}
